﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
namespace DAO
{
    public class ChuyenBayDAO
    {
        DataTable dt;
        List<string> dsThamSo;
        ArrayList dsGiaTri;
       
        
        public ChuyenBayDAO()
        {
            dt = new DataTable();
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            
        }
        public DataTable TimKiemChuyenBay(string maSanBayDi, string maSanBayDen, string thoiGianDi)
        {
      
            dsThamSo.Add("@thoiGianDi");
            dsThamSo.Add("@maSanBayDi");
            dsThamSo.Add("@maSanBayDen");
            dsGiaTri.Add(thoiGianDi);
            dsGiaTri.Add(maSanBayDi);
            dsGiaTri.Add(maSanBayDen);
            dt = DataProvider.ExecuteStoreProc("sp_TimChuyenbay", dsThamSo, dsGiaTri);
            return dt;
        }
        public DataTable TimKiemChuyenBayTheoTieuChi(string maSanBayDi, string thoiGianDi,string proc)
        {

            dsThamSo.Add("@thoiGianDi");
            dsThamSo.Add("@maSanBay");
           
            dsGiaTri.Add(thoiGianDi);
            dsGiaTri.Add(maSanBayDi);

            dt = DataProvider.ExecuteStoreProc(proc, dsThamSo, dsGiaTri);
            return dt;
        }
        public DataTable TimKiemChuyenBay(string maSanBayDi, string maSanBayDen, string thoiGianDi,string proc)
        {
       
           
            dsThamSo.Add("@thoiGianDi");
            dsThamSo.Add("@maSanBayDi");
            dsThamSo.Add("@maSanBayDen");
            dsGiaTri.Add(thoiGianDi);
            dsGiaTri.Add(maSanBayDi);
            dsGiaTri.Add(maSanBayDen);
            dt = DataProvider.ExecuteStoreProc(proc, dsThamSo, dsGiaTri);
            return dt;
        }

        public DataTable layThongTinVeDoiLichTrinh(string maKhachHang,string ngayDat)
        {


            dsThamSo.Add("@maKhachHang");
            dsThamSo.Add("@ngayDat");
            
            dsGiaTri.Add(maKhachHang);
            dsGiaTri.Add(ngayDat);

            dt = DataProvider.ExecuteStoreProc("sp_layThongTinVeDaDoiLichTrinh", dsThamSo, dsGiaTri);
            return dt;
        }

        public DataTable layThongTinChuyenBay(string ngayDat)
        {
                     
            dsThamSo.Add("@ngayDi");

            dsGiaTri.Add(ngayDat);

            dt = DataProvider.ExecuteStoreProc("sp_loadChuyenBay", dsThamSo, dsGiaTri);
            return dt;
        }
        public DataTable layThongTinChuyenBay()
        {
            dt = DataProvider.ExecuteStoreProc("sp_loadChuyenBayFull", null,null);
            return dt;
        }
        public int themMoiChuyenbay(string maChuyenBay,int IDmayBay,float chiPhiDichVuDuKien)
        
        {
            int n = 0;
            string sql = "insert into ChuyenBay values('" + maChuyenBay + "'," + IDmayBay + ",NULL,1,'False',"+chiPhiDichVuDuKien+",0)";
            n = DataProvider.ExecuteNoneQuery(sql);
            return n;
        }
        public int demSoChuyenBay()
        {
            dt = new DataTable();
        
            dt = DataProvider.ExecuteStoreProc("sp_demSoChuyenBay", null, null);
            return dt.Rows.Count;
        }
        public DataTable layThongTinChuyenBayChangBay(int maChangBay, string ngayDi)
        {
            dt = new DataTable();
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            dsThamSo.Add("@maChangBay");
            dsThamSo.Add("@ngayDi");
            dsGiaTri.Add(maChangBay);
            dsGiaTri.Add(ngayDi);
            dt = DataProvider.ExecuteStoreProc("sp_layThongTinChuyenBayChangBay",dsThamSo,dsGiaTri);
            return dt;

        }
        public void capNhatChiPhiChuyenBay(string maChuyenBay, float nhienLieu, float chiPhi)
        {
            string sql = "update ChuyenBay set nhienLieuTieuThu = " + nhienLieu + ",chiPhiDichVuThucTe = " + chiPhi + " where ID_chuyenBay = '" + maChuyenBay + "'";
            DataProvider.ExecuteNoneQuery(sql);
        }
    }

}
